package com.evl.config.properties;

import static com.evl.core.util.ToolUtil.getTempPath;
import static com.evl.core.util.ToolUtil.isEmpty;

import java.io.File;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * guns项目配置
 *
 * @author yangliwei
 * @Date 2017/5/23 22:31
 */
@Component
@ConfigurationProperties(prefix = TravelticketsProperties.PREFIX)
public class TravelticketsProperties {

    public static final String PREFIX = "guns";

    private Boolean kaptchaOpen = false;

    private Boolean swaggerOpen = true;

    private String fileUploadPath;

    private Boolean haveCreatePath = false;

    private String qrcodeUploadPath;
    
    
    public String getFileUploadPath() {
        //如果没有写文件上传路径,保存到临时目录
        if(isEmpty(fileUploadPath)){
            return getTempPath();
        }else{
            //判断有没有结尾符,没有得加上
            if(!fileUploadPath.endsWith(File.separator)){
                fileUploadPath = fileUploadPath + File.separator;
            }
            //判断目录存不存在,不存在得加上
            if(haveCreatePath == false){
                File file = new File(fileUploadPath);
                file.mkdirs();
                haveCreatePath = true;
            }
            return fileUploadPath;
        }
    }

    public void setFileUploadPath(String fileUploadPath) {
        this.fileUploadPath = fileUploadPath;
    }

    public Boolean getKaptchaOpen() {
        return kaptchaOpen;
    }

    public void setKaptchaOpen(Boolean kaptchaOpen) {
        this.kaptchaOpen = kaptchaOpen;
    }

    public Boolean getSwaggerOpen() {
        return swaggerOpen;
    }

    public void setSwaggerOpen(Boolean swaggerOpen) {
        this.swaggerOpen = swaggerOpen;
    }

	public String getQrcodeUploadPath() {
		return qrcodeUploadPath;
	}

	public void setQrcodeUploadPath(String qrcodeUploadPath) {
		this.qrcodeUploadPath = qrcodeUploadPath;
	}
    
}
